package com.newcoder.community.dao;

import com.newcoder.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * @author edison
 * @version 2023
 * @date 2024/1/20 17:28
 */

@Mapper
public interface LoginTicketMapper {
    //插入登录凭证
    @Insert({
            "insert into login_ticket (user_id, ticket, status, expired) ",
            "values(#{userId}, #{ticket}, #{status}, #{expired})"
    })
    @Options(keyProperty = "id")
    int insertLoginTicket(LoginTicket loginTicket);

    //根据凭证查询登录凭证
    @Select({
            "select id, user_id, ticket, status, expired ",
            "from login_ticket where ticket = #{ticket}"
    })
    LoginTicket selectByTicket(@Param("ticket") String ticket);

    //更新登录凭证状态
    @Update({
            "update login_ticket set status = #{status} where ticket = #{ticket}"
    })
    int updateStatus(@Param("ticket") String ticket, @Param("status") int status);

}
